package test;


import storage.data.StorageInterface;
import Common.GlobalConst;
import Common.GoggleDB;
import Metadata.HeapfileInterface;
import Metadata.TableMgr;
import Metadata.tableSchema;
import SQL.plan.Plan;
import SQL.planner.Planner;
import SQL.query.Select;
import SQL.scan.Scan;
import Transaction.Transaction;

//import storage.data.DataBaseFile;

public class test_basic {
	public static void main(String args[]) throws Exception
	{
		new GoggleDB("test", 500);
		Planner planner=new Planner();
		planner.getExecute("CREATE DATABASE test",null);
		//planner.getExecute("CREATE TABLE conglei (AZURENAME CHAR(10),AZURENO INT,primary key(AZURENO))","test");
		Transaction tx=new Transaction();
		tableSchema record=new tableSchema();
//		GoggleDB.tableMgr.getInfo("tableCatalog", record, tx);
		planner.getExecute("CREATE TABLE t1 (s1 INT)","test");
		planner.getExecute("INSERT INTO t1 VALUES (1)","test");
		planner.getExecute("CREATE TABLE t2 (s1 INT)","test");
		planner.getExecute("INSERT INTO t2 VALUES (2)","test");
		planner.getExecute("INSERT INTO t1 (SELECT * FROM t2)","test");
//		planner.getExecute("CREATE TABLE t3 (s1 INT)","test");
//		planner.getExecute("INSERT INTO t3 VALUES (2)","test");
		//planner.getExecute("UPDATE conglei SET AZURENAME = \"AAAAA\"", "test");
		//planner.getExecute("DELETE FROM conglei WHERE AZURENO > 5", "test");
		//GoggleDB.storageInterface.get_db_by_name("test");
		GoggleDB.bufferMgr.flushAll();
//		Plan p = planner.getExecute("SELECT s1,s1 FROM t1,t2 WHERE s1 = s2","test");
		Plan p = planner.getExecute("SELECT * FROM t1", "test");
		Scan s = p.open();
		s.getSchema();
		while(s.next()!=null){
			System.out.println(s.getCurrent().toString());
		}
		
		GoggleDB.bufferMgr.flushAll();
		GoggleDB.timer.cancel();
	}
}
